package net.net23.sysdent.ui;

import java.util.Set;

import org.fife.ui.autocomplete.AutoCompletion;
import org.fife.ui.autocomplete.BasicCompletion;
import org.fife.ui.autocomplete.DefaultCompletionProvider;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;

public class JDBCEXplorerAutocompleteComponent extends AutocompleteComponent {

	private RSyntaxTextArea query;

	public JDBCEXplorerAutocompleteComponent(RSyntaxTextArea query) {
		this.query = query;
	}

	@Override
	public void setupAutocomplete() {
		if (providers != null) {
			DefaultCompletionProvider provider = new DefaultCompletionProvider();
			for (Set<String> set : providers) {
				if (set != null) {
					for (String string : set) {
						provider.addCompletion(new BasicCompletion(provider,
								string));
					}
				}
			}
			AutoCompletion ac = new AutoCompletion(provider);
			ac.install(query);
		}
	}

}
